<template>
	<view class="pad-lr-30">
		<view class="mar-top-30 fontSize-30">问题描述</view>
		<view class="bgf6  pad-lr-20 pad-tb-20 radius-16 mar-top-20">
			<textarea name="" maxlength="-1" class="width-100 fontSize-28" v-model="feedback" placeholder="填写反馈内容" id="" cols="30" rows="10"></textarea>
		</view>
		<view class="mar-top-30 fontSize-30">联系电话</view>
		<view class="bgf6  pad-lr-20 pad-tb-20 radius-16 mar-top-20">
			<input type="number" maxlength="11" v-model="phone" placeholder="填写联系电话" class="width-100" />
		</view>
		<view class="mar-top-30 fontSize-30">上传图片</view>
		<view class="pad-tb-30">
			<o-upload :imageHeight="200" :maxFile="9"  @success="successimg"></o-upload>
		</view>
		<view class="text-align-center col-f fontSize-32 radius-40 fa_btn" @click="_suggestion_sub">
			提交
		</view>
	</view>
</template>

<script lang="ts" setup>
// import {suggestion_sub} from '@/utils/api'
import {judgeTel} from '@/utils/utils'
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
onLoad(()=>{
	
})
const phone = ref(),
	  feedback = ref();
//上传图片
const images = ref()
const successimg =(e,fileList) =>{
	console.log(e,fileList,18)
	let imglist = []
	fileList.forEach(item=>{
		imglist.push(JSON.parse(item.response).data.file.url)
		images.value = imglist
	})
}
const _suggestion_sub =() =>{
	if(!judgeTel(phone.value)){
		uni.showToast({
			title:'手机号不合法',
			icon:'none'
		})
		return
	}
	suggestion_sub({
		img:images.value?images.value.join(','):'',
		feedback:feedback.value,
		phone:phone.value
	}).then(res=>{
		uni.showToast({
				icon: 'none',
				title:res.msg
			})
		if(res.code==1){
			uni.$emit('updatayijian')
			setTimeout(()=>{
				uni.navigateBack({
					delta:1
				})
			},1500)
		}
	})
}
</script>

<style lang="scss">
@import 'writefeedback.scss';
</style>
